package cn.sccl.mybatis.dao;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.support.SqlSessionDaoSupport;

import cn.sccl.mybatis.pojo.User;

/**
 * @author 饶爽
 * @time 2019年10月7日 下午11:15:09
 * @version 1.0.1
 * 原始Dao开发
 */
public class UserDaoImpl extends SqlSessionDaoSupport implements UserDao {
    
    @Override
    public User queryUserById(int id) {
        SqlSession session = super.getSqlSession();
        User user = session.selectOne("test.queryUserById", id);
        return user;
    }

    @Override
    public List<User> queryUserByUsername(String username) {
        SqlSession session = super.getSqlSession();
        List<User> list = session.selectList("test.queryUserByUsername",username);
        return list;
    }

    @Override
    public void saveUser(User user) {
        SqlSession session = super.getSqlSession();
        session.insert("test.saveUser",user);
    }
}
